package com.bcbim.api_web.table_head.controller;

import com.bcbim.authentication_interface.util.AuthUtil;
import com.bcbim.common.response.vo.ReturnMsg;
import com.bcbim.operation_maintenance_interface.table_head.service.SpaceOccupyTableHeadService;
import com.bcbim.operation_maintenance_interface.table_head.vo.SpaceOccupyTableHeadVO;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 空间占用表头设置Controller
 * @Author lihonggang
 * @Date 2022/04/28  17:52
 * @Version V1.0
 **/
@RestController
@RequestMapping("/spaceOccupyTableHead")
public class SpaceOccupyTableHeadController {

    @Reference(protocol = "dubbo", group = "spaceOccupyTableHead", version = "1.0.0")
    private SpaceOccupyTableHeadService spaceOccupyTableHeadServiceImpl;
    /**
     * @Description:  查询空间占用表头设置列表
     * @Date:  2022/4/28 18:11
     * @Param: [] 
     * @return: com.bcbim.common.response.vo.ReturnMsg
     * @Author: lihonggang
     **/
    @RequestMapping("/listSpaceOccupyTableHead")
    public ReturnMsg listSpaceOccupyTableHead() {
        String userId = null;
        //判断用户是否设置过表头
        int count = spaceOccupyTableHeadServiceImpl.checkSpaceTableHeadByUserId(AuthUtil.getUserIdDecrypt());
        if (count > 0) {
            userId = AuthUtil.getUserIdDecrypt();
        }
        //查询用户设置过的
        List<SpaceOccupyTableHeadVO> list = spaceOccupyTableHeadServiceImpl.listSpaceOccupyTableHead(userId);
        return ReturnMsg.consSuccess(list);
    }
}
